package net.kangyee.eventmanager.commands;

import org.bukkit.entity.Player;

import net.kangyee.eventmanager.EventManager;
import net.kangyee.eventmanager.util.ConfigManager;
import net.kangyee.eventmanager.util.MessageManager;

public class CmdQuit extends EventManagerCommand {

	private EventManager plugin;
	private ConfigManager config;

	public CmdQuit(EventManager plugin, ConfigManager config) {
		this.plugin = plugin;
		this.config = config;
	}

	public void onCommand(Player player, String[] args) {
		if (!plugin.regPlayers.containsKey(player)) {
			MessageManager.sendNormalMessage(player, "&c你还未报名参加任何活动");
			return;
		}
		plugin.resetPlayer(player);
		MessageManager.sendNormalMessageToAll(config.messageQuit.replaceAll("%name%", player.getDisplayName())
				.replaceAll("%event%", plugin.getEventName())
				.replaceAll("%count%", String.valueOf(plugin.getRegCount())));
		MessageManager.sendNormalMessage(player, "&f你退出了活动:&6" + plugin.getEventName());
		return;
	}

	public String getCmdName() {
		return "quit";
	}

	public String getArgs() {
		return "";
	}
	
	public int getMaxArgs() {
		return 1;
	}

	public int getMinArgs() {
		return 1;
	}

	public String getPermission() {
		return "eventmanager.player." + getCmdName();
	}

	public boolean getStateRequire() {
		return true;
	}
	
	public boolean getRegPCRequire() {
		return false;
	}
}
